#include "power_meter.h"
#include "monitor.h"

power_meter_struct power_meter_data = {};

void power_meter_callback(CAN_RxHeaderTypeDef* rx_header, uint8_t* data)
{
	power_meter_data.voltage = (float)(data[1] << 8 | data[0]) / 100.0f;
	power_meter_data.current = (float)((int16_t)(data[3] << 8 | data[2])) / 100.0f;
	power_meter_data.power = power_meter_data.voltage * power_meter_data.current;
	
	monitor_refresh(&monitor_power_meter_online);
}